console.log("7quickSelect");
let utils = data["utils"];
let RBushItem = data["RBushItem"];
let RBU = data["RBU"];
let RBush = data["RBush"];
let AreaForRender = data["AreaForRender"];
let LeftNumFunnel = data["LeftNumFunnel"];


function swap(arr, i, j) {
  var tmp = arr[i];
  arr[i] = arr[j];
  arr[j] = tmp;
}

function defaultCompare(a, b) {
  return a < b ? -1 : a > b ? 1 : 0;
}

function quickselect(arr, k, left, right, compare) {
  for (; right > left;) {
    if (right - left > 600) {
      var n = right - left + 1,
        m = k - left + 1,
        z = Math.log(n),
        s = .5 * Math.exp(2 * z / 3),
        sd = .5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1),
        newLeft = Math.max(left, Math.floor(k - m * s / n + sd)),
        newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
      quickselect(arr, k, newLeft, newRight, compare);
    }
    var t = arr[k],
      i = left,
      j = right;
    swap(arr, left, k);
    compare(arr[right], t) > 0 && swap(arr, left, right);
    for (; i < j;) {
      swap(arr, i, j);
      i++;
      j--;
      for (; compare(arr[i], t) < 0;) i++;
      for (; compare(arr[j], t) > 0;) j--;
    }
    if (0 === compare(arr[left], t)) swap(arr, left, j);
    else {
      j++;
      swap(arr, j, right);
    }
    j <= k && (left = j + 1);
    k <= j && (right = j - 1);
  }
}

return {
  "utils": utils,
  "RBushItem": RBushItem,
  "RBU": RBU,
  "RBush": RBush,
  "AreaForRender": AreaForRender,
  "LeftNumFunnel": LeftNumFunnel,
  "quickselect": quickselect
}